package com.haizhi.crm.sys.configure.dao;

import com.haizhi.crm.sys.configure.model.UserModuleSettingDo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by caochao on 2018/05/31.
 */
@Repository
public interface UserModuleSettingDao extends JpaRepository<UserModuleSettingDo, Long> {

    @Query(value = "select m from UserModuleSettingDo m where userModuleId = ?1" )
    List<UserModuleSettingDo> findByUserModuleId(Long userModuleId);


    @Query(value = "select m from UserModuleSettingDo m where userModuleId = ?1 and settingId = ?2" )
    UserModuleSettingDo findByUserModuleIdAndSettingId(Long userModuleId, Long settingId);

    @Query(value = "delete from UserModuleSettingDo m where userModuleId = ?1 " )
    @Modifying
    void deleteByUserModuleId(Long userModuleId);

}
